package com.diligreat.action; 

import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.struts2.ServletActionContext;

import com.diligreat.action.base.BaseAction;
import com.diligreat.service.ContentService;

/**  
 * @Author Bruce 
 * @Date 2012-11-18
 * @Comments
 */
public class FileDownloadAction extends BaseAction {
	private static final long serialVersionUID = 1L;

	private String inputPath;
	private String contentType;
	private String fileName;
	
	private static final String path = "/PDF/";
			
	public InputStream getInputStream() throws Exception{
		System.out.println(">>>>>>>"+ServletActionContext.getServletContext().getResourceAsStream(inputPath));
		return ServletActionContext.getServletContext().getResourceAsStream(inputPath);
	}

	@Override
	public String execute() throws Exception {
		//fileName = new String(fileName.getBytes("ISO-8859-1"), "GBK");
		inputPath = path + File.separator + new String(fileName.getBytes("ISO-8859-1"), "GBK");
		contentType = "application/pdf";
		return SUCCESS;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	
}
 